!{include file='common/iheader.htm'}
<style>
</style>
<div id="i_nav">
	<h3 class="page_title">网站模板管理</h3>
	<a class="button template_add" href="javascript:void(0)">添加页面</a>
</div>
<table class="list_table">
	<tr><th>名称</th><th>是否发布</th><th>更新时间</th><th>操作</th></tr>
	!{foreach from=$pages item=p key=k}
	<tr id="t_!{$p._id}">
		<td>!{$p.page_name}[!{$p.name}] !{if $p.desc}<span>(!{$p.desc})</span>!{/if}</td>
		<td>!{if $p.available eq true}<span class="ui-icon ui-icon-check"></span>!{else}<span class="ui-icon ui-icon-close"></span>!{/if}</td>
		<td>!{$p.update|date_format:"%Y-%m-%d %H:%M:%S"}</td>
		<td>
			复制
			<a href="!{$p.url}&edit=1!{if $p.available eq false}&tpl_id=!{$p._id}!{/if}" target="_blank">编辑</a>
			<a href="javascript:void(0)" onclick="template_public('!{$p._id}')">发布</a>
			<a href="javascript:void(0)" onclick="template_del('!{$p._id}')">删除</a>
			预览
		</td>
	</tr>
	!{foreachelse}
	<tr><td colspan="4">暂无页面模板</td></tr>
	!{/foreach}
</table>
<div class="option_div">
	<div class="pager">
	!{include file='common/pager.htm'}
	</div>
</div>
<div class="dialog" id="add_form" title="添加模版"></div>
<script>
	$(function(){
		$(".template_add").click(function(){
			$("#add_form").dialog({width:500,modal:true}).html('正在加载...').load('/manager.php?app=file&act=template_edit');
		});
	});

	function template_add(){
		
	}

	function template_public(id){
		if(confirm("发布会将原来的发布页面转为非发布，是否继续？")){
			$.get('/manager.php?app=file&act=template_public&id=' + id, function(data){
				var json = eval('('+data+')');
				alert(json.info);
				if(json.result){
					//发布成功，刷新本页面
					window.location.reload();
				}
			});
		}
	}
	
	function template_del(id){
		if(confirm("删除将无法恢复，是否继续？")){
			$.get('/manager.php?app=file&act=template_del&id=' + id, function(data){
				var json = eval('('+data+')');
				alert(json.info);
				if(json.result){
					//删除成功
					$("#t_" + id).remove();
				}
			});
		}
	}
</script>
!{include file='common/ifooter.htm'}